#!/bin/sh
set -e

SCRIPTPATH=`dirname $0`

cd $SCRIPTPATH

set -a
if [ -f ../../.env ]; then . ../../.env; fi
DATABASE_URL=${MYSQL_EXAMPLE_DATABASE_URL}
if [ -z "$BACKEND" ]; then
    export BACKEND="mysql"
fi
set +a

if [ -z "${BACKEND##*mysql*}" ]; then
  for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do
    cd $dir
    ../../../bin/diesel database reset
    cargo build
    cd ..
  done
fi
